package com.haisen.controller;


import com.haisen.core.utils.Result;
import com.haisen.dataobject.entity.Dic;
import com.haisen.service.DicService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.weekend.Weekend;
import tk.mybatis.mapper.weekend.WeekendCriteria;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Controller
@RequestMapping("/common")
@Slf4j
public class CommonController {

    @Autowired
    private DicService dicService;


    @GetMapping("/dic/biztail")
    @ResponseBody
    public Result autoComplete(@RequestParam("name") String name,@RequestParam("type") String type){
        log.info("收到参数 ,name={},type={}",name,type);
       Map<String,String>  map = dicService.GetDic("tb_buss_item","biz_detail");
     List<String> retList  = map.entrySet().stream().filter(o ->{
           if (o.getValue().indexOf(name) !=-1){
               return true;
           } else return false;
       }).map( o ->{
           return o.getValue();
       }).collect(Collectors.toList());
        return Result.success(retList);
    }
}
